Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4/5]: lnwallet: add new AuxSigner interface to mirror SigPool #8632

Merged
merged 3 commits into from
May 27, 2024

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Apr 9, 2024

Depends on #8622.

In this PR, we add a new aux signer interface that's meant to mirror the SigPool. If present, this'll be used to (maybe) obtain signatures for second level HTLCs for certain classes of custom channels.

TODO

  • merge sigs into existing tlv.Blob on disk for HTLCs

Link to all PRs in the saga:

Copy link
Contributor

coderabbitai bot commented Apr 9, 2024

Important

Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Apr 9, 2024

Pull reviewers stats

Stats of the last 30 days for lnd:

User Total reviews Time to review Total comments
guggero
🥇
21
▀▀▀
2d 11h 48m
58
▀▀▀
ellemouton
🥈
12
▀▀
1d 22h 6m
20
bhandras
🥉
9
30m
0
yyforyongyu
6
3h 18m
0
Roasbeef
5
1d 19h 36m
6
ziggie1984
5
3d 1h 5m
14
ProofOfKeags
4
4d 6h 9m
41
▀▀
GeorgeTsagk
4
2d 20h 31m
10
bitromortac
2
13d 3h 49m
▀▀
6
saubyk
2
5h 24m
0
Chinwendu20
2
18d 5h 38m
▀▀
9
positiveblue
1
4d 21h 57m
0
AndySchroder
1
17d 9h 5m
▀▀
4
ffranr
1
14h 10m
4
Crypt-iQ
1
7d 14h 36m
4
dstadulis
1
1d 22h 10m
4
morehouse
1
2d 2h 39m
1
carlaKC
1
12h 2m
0
mohamedawnallah
1
1d 4h 44m
0

@guggero guggero force-pushed the aux-leaf-signing branch 2 times, most recently from 54509a9 to 1858e19 Compare April 24, 2024 15:04
@guggero guggero changed the title lnwallet: add new AuxSigner interface to mirror SigPool [4/?]: lnwallet: add new AuxSigner interface to mirror SigPool Apr 24, 2024
@guggero guggero force-pushed the aux-leaf-signing branch 3 times, most recently from 8ed50cf to cfd4314 Compare May 1, 2024 13:53
@guggero guggero force-pushed the aux-funding branch 2 times, most recently from fc74f55 to 57adb13 Compare May 17, 2024 11:31
@guggero
Copy link
Collaborator

guggero commented May 17, 2024

Included all changes from the PoC branch, ready for first pass review.

@guggero guggero changed the title [4/?]: lnwallet: add new AuxSigner interface to mirror SigPool [4/5]: lnwallet: add new AuxSigner interface to mirror SigPool May 17, 2024
@guggero guggero force-pushed the aux-leaf-signing branch 2 times, most recently from 6123a1c to e258b87 Compare May 21, 2024 07:46
Copy link
Collaborator

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple, clean diff ✨

Would be nice to mock the AuxSigner and have some simple tests to verify the htlc sig processing flows & generated ExtraData

Could def make a TODO for when we're done with the saga, or perhaps coverage is introduced in a latter PR so I'll keep an eye on this 👀

LGTM


// AuxLeafStore is an optional data source that can be used by custom
// channels to fetch+store various data.
AuxLeafStore fn.Option[lnwallet.AuxLeafStore]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this here / being removed now?

Copy link
Collaborator

@guggero guggero May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just in the wrong place, moved it to the AuxComponents sub struct. When we just had a single aux interface it made sense here, as "store" vaguely has something to do with database. But with all the other components it made sense to move everything to its own struct.

lnwallet/channel.go Outdated Show resolved Hide resolved
// AuxSigner is an interface that is used to sign and verify HTLCs for custom
// channels. It is similar to the existing SigPool, but uses opaque blobs to
// shuffle around signature information and other metadata.
type AuxSigner interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to mock this and have some minimal test coverage

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to the tracking issue, since we currently don't have any coverage for those aux interfaces.

Copy link
Collaborator

@ffranr ffranr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

type BaseAuxJob struct {
// OutputIndex is the output index of the HTLC on the commitment
// transaction being signed.
OutputIndex int32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be unsigned int rather than signed?

Copy link
Collaborator

@guggero guggero May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value comes from here: https://github.com/lightningnetwork/lnd/blob/a350ccd7/lnwallet/channel.go#L308
So it can actually be negative. Added the same comment here.

lnwallet/commitment.go Outdated Show resolved Hide resolved
In this commit, we add a new aux signer interface that's meant to mirror the SigPool. If present, this'll be used to (maybe) obtain signatures for second level HTLCs for certain classes of custom channels.
In this commit, we start to use the new AuxSigner to obtain+verify aux sigs for all second level HTLCs. This is similar to the existing SigPool, but we'll only attempt to do this if the AuxSigner is present (won't be for most channels).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants